//
//  U3DVC.swift
//  Auscultation
//
//  Created by zwb on 2021/3/27.
//

import UIKit

class U3DVC: BaseVC {
    
    var studyCompeleCourse:(()->Void)?

    override func viewDidLoad() {
        super.viewDidLoad()
        isHorizontalScreen = true
        isHiddenNavigationBar = true
//        if let unityview = UnityGetGLView() {
//            unityview.frame = CGRect(x:0,y:0,width:UIDevice.lgf_ScreenW,height:UIDevice.lgf_ScreenH);
//            unityview.center = self.view.center
//            self.view.addSubview(unityview)
//            self.view.bringSubviewToFront(unityview)
//             let btn  = UIButton(frame: CGRect(x: UIDevice.lgf_ScreenH - 130, y: 5,   width: 30, height: 30))
//            self.view.addSubview(btn)
//            btn.addTarget(self, action: #selector(popclick), for: .touchUpInside)
//            btn.setImage(UIImage(named: "guanbi"), for: .normal)
//            self.view.bringSubviewToFront(btn)
//        }
//        GetAppController()?.quitHandler = {
//            if let appDelegate = UIApplication.shared.delegate as? AppDelegate
//            {
//              appDelegate.isUnityRunning = false
//            }
//            self.navigationController?.popViewController(animated: true)
//        }
    }
    
    @objc func popclick(){
        studyCompeleCourse?()
        self.navigationController?.popToRootViewController(animated: true)
        // 关闭u3d中的音频
//        UnitySendMessage("MainDATA","IOSTODATA","1");

    }
    
    @objc func receiveNotification(noti:Notification){
        print("u3dStarted")
        DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
//            if let unityview = UnityGetGLView() {
//                unityview.frame = CGRect(x:0,y:0,width:UIDevice.lgf_ScreenW,height:UIDevice.lgf_ScreenH);
//                unityview.center = self.view.center
//                self.view.addSubview(unityview)
//                self.view.bringSubviewToFront(unityview)
//            }

        }
    }
    
    deinit {
        NotificationCenter.default.removeObserver(self)
    }

}
